<template>
    <div>
        <h3>新闻详情----
            <!-- {{id}} -->
            </h3>
            <p class="title">
                <span>发表时间：{{data | dateFormat}}</span>
                <span>点击：1次</span>
            </p>
            <hr>
            <!-- 新闻内容 -->
            <div class="content" v-html="c">

            </div>
            <!-- 这是评论组件的位置
             -->
             <comment></comment>
             <!-- 父组件向子组件传值，通过属性绑定的形式 -->
             <!-- <comment :newsid="id"></comment> -->
    </div>
</template>

<script>
// 导入comment.vue子组件
import comment from '../sub-components/Comment.vue'
export default {
  data() {
      return {
          c:"<p>dasdasdsadasdasdasdasdasda</p><p>sddasdasdsadasdasdasdasdasdasddasdasdsadasdasdasdasdasdasddasdasdsadasdasdasdasdasdasd</p>",
          date :"2012-12-12 12:12:12",
          newsinfo:[]
      }
  },
  methods: {
    async  getNewsInfo(){
        //   根据id获取新闻的详情
     const {data}  =await  this.$http.get("url")
    //  const {data}  =await  this.$http.get("url"+this.id)
     if(data.status===0) return (this.newsinfo=data.message[0])
      }
  },
//   props:['id']
    created() {
    this.getNewsInfo()
},
    components:{
        // 为当前组件注册私有的子组件
        comment
    }
}
</script>

<style lang="less" scoped>
.title{margin: 3px;
    display: flex;
    justify-content: space-between;
}
</style>